<?php
/**
 * 用户相关接口请求参数验证器
 * User: 发仔<i@fazi.me>
 * Date: 2018/08/008
 */

namespace app\open\validate;

use app\base\validate\BaseValidate;

class UserValidate extends BaseValidate
{
    protected $rule = [
        'username' => 'require|max:50',
        'password' => 'require|max:50',
        'mobile' => 'require|isMobile',
        'code' => 'require|integer|length:6',
    ];

    protected $message = [
        'username.require' => '用户名不能为空',
        'password.require' => '密码不能为空',
        'mobile.require' => '手机号不能为空',
        'mobile.isMobile' => '手机号格式不正确',
        'code.length' => '短信验证码为6位数字'
    ];

    protected $scene = [
        'add' => [
          'username',
          'password',
          'mobile',
          'area_id',
          'role_id',
        ],
        'edit' => [
            'user_id',
            'username',
            'mobile',
            'area_id',
            'role_id',
        ],
        'login' => ['username', 'password'],
        'sms' => ['mobile', 'code'],
        'get_sms_code' => ['mobile'],
    ];
}